package 设计模式.Test.test01;

import java.util.Objects;

/**
 * @Author: kirito
 * @Date: 2024/4/3 13:05
 * @Description:
 *
 */

public abstract class AbstractBusinessChain implements BusinessChain{
    protected BusinessChain next;

    private Boolean hasNext() {
        return Objects.nonNull(next);
    }

    @Override
    public void process(Object param) {
        Boolean r = executeProcess(param);
        if (Boolean.FALSE.equals(r) && Boolean.TRUE.equals(hasNext())) {
            next.process(param);
        }
    }

    protected abstract Boolean executeProcess(Object param);

    @Override
    public void setNext(BusinessChain next) {
        this.next = next;
    }
}
